package com.customfmxt;

import java.io.File;
import java.io.IOException;
import java.util.List;

import javax.swing.JOptionPane;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
//import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.entity.Damageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
//import net.minecraft.server.v1_12_R1.NBTTagCompound;

public class project extends JavaPlugin implements Listener {
	String Priex = getConfig().getString("Priex.Priex");
	int ChangeMaxHealth = 0;
	public static Entity FEntity;
	public static String version="";

	public static String getSubString(String text, String left, String right) {
		String result = "";
		int zLen;
		if (left == null || left.isEmpty()) {
			zLen = 0;
		} else {
			zLen = text.indexOf(left);
			if (zLen > -1) {
				zLen += left.length();
			} else {
				zLen = 0;
			}
		}
		int yLen = text.indexOf(right, zLen);
		if (yLen < 0 || right == null || right.isEmpty()) {
			yLen = text.length();
		}
		result = text.substring(zLen, yLen);
		return result;

	}
	public void onLoad() {
		saveDefaultConfig();
		reloadConfig();
		getLogger().info("封魔系统重置版插件已加载");
		getLogger().info("插件作者QQ:1242839141");
		getLogger().info("严禁倒卖,修改版权行为.");
		version = Bukkit.getVersion();
		version = getSubString(version, "(MC: ", ")");
	}

	public void onEnable() {

		getServer().getPluginManager().registerEvents(this, this);
		getLogger().info("封魔系统重制版已启动");
		getLogger().info("插件作者QQ:1242839141");
		getLogger().info("严禁倒卖,修改版权行为.");

		File f  = new File("");
		String Tempf0 = null;
		try {
			Tempf0 = f.getCanonicalPath();
		} catch (IOException e1) {
			// TODO 自动生成的 catch 块
			e1.printStackTrace();
		}


		String Tempf = Tempf0 + "\\";
		File f2 = new File(Tempf,"spigot.yml");
		FileConfiguration spigot = (FileConfiguration)YamlConfiguration.loadConfiguration(f2);
		if(spigot.getDouble("settings.attribute.maxHealth.max") == 2048.0) {
			ChangeMaxHealth = 1;
			spigot.set("settings.attribute.maxHealth.max", 10000000000000000.00);
			try {
				spigot.save(f2);
			} catch (IOException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}
			getLogger().info("已为您自动设置服务端血量上限突破");
		}


		if(ChangeMaxHealth == 1) {
			JOptionPane.showMessageDialog(null,"服务器开启完毕后将自动重启,已为您自动修改血量上限设置成功！");
			Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "stop");
		}




	}

	public void onDisable() {
		getLogger().info("封魔系统已卸载");
		getLogger().info("插件作者QQ:1242839141");
		getLogger().info("严禁倒卖,修改版权行为,");
		getServer().getPluginManager().disablePlugin(this);
	}




	@EventHandler
	public void onPlayerEntityInteract(PlayerInteractEntityEvent event){
		Player player = event.getPlayer();
		if(!(player.isOp())) {
			return;
		}
		ItemStack item = player.getItemInHand();
		if(item.getType() != Material.BLAZE_ROD) {
			return;
		}
		Entity Entity = event.getRightClicked();

		if(!(Entity instanceof Damageable)) {
			return;
		}
		Damageable damageable = (Damageable) Entity;

		FEntity = event.getRightClicked();
		String CustomName = null;
		if(version.equals("1.7.10")) {
			CustomName = R1_7_10.get();
		}else if(version.equals("1.12.2")){
			CustomName = R1_12_2.get();
		}else if(version.equals("1.16.1")){
			CustomName = R1_16_1.get();
		}else if(version.equals("1.14.4")){
			CustomName = R1_14_4.get();
		}
		player.sendMessage("§d----------§b[参数获取]§d----------");
		player.sendMessage("§d获取的实体名:" + CustomName);
		player.sendMessage("§d获取的怪物最大血量:" + damageable.getMaxHealth());
		player.sendMessage("§d----------§b[参数获取]§d----------");
	}






	@EventHandler
	public void onCreatureSpawn(CreatureSpawnEvent e) {




		new BukkitRunnable() {
			@Override
			public void run() {
				if(getConfig().getBoolean("DeBug.Switch") == true) {
					FEntity = e.getEntity();
					String GetTrueName = null;
					if(version.equals("1.7.10")) {
						GetTrueName = R1_7_10.get();
					}else if(version.equals("1.12.2")){
						GetTrueName = R1_12_2.get();
					}else if(version.equals("1.16.1")){
						GetTrueName = R1_16_1.get();
					}else if(version.equals("1.14.4")){
						GetTrueName = R1_14_4.get();
					}else if(version.equals("1.7.2")){
						GetTrueName = R1_7_2.get();
					}else if(version.equals("1.6.4")){
						GetTrueName = R1_6_4.get();
					}
					
					
					Bukkit.broadcastMessage("§d----------§b[参数获取]§d----------");
					Bukkit.broadcastMessage("§d获取的实体名:" + GetTrueName);
					Bukkit.broadcastMessage("§d----------§b[参数获取]§d----------");	
				}
				FEntity = e.getEntity();
				String SpawnName = null;
				
				
				
				
				if(version.equals("1.7.10")) {
					SpawnName = R1_7_10.get();
				}else if(version.equals("1.12.2")){
					SpawnName = R1_12_2.get();
				}else if(version.equals("1.16.1")){
					SpawnName = R1_16_1.get();
				}else if(version.equals("1.14.4")){
					SpawnName = R1_14_4.get();
				}else if(version.equals("1.7.2")){
					SpawnName = R1_7_2.get();
				}else if(version.equals("1.6.4")){
					SpawnName = R1_6_4.get();
				}
				
				if(e.getEntity().getType().getName().equalsIgnoreCase("Botania-botaniadoppleganger") ||SpawnName.equalsIgnoreCase("Guardian-of-Gaia")) {
					FEntity = e.getEntity();
					if(version.equals("1.7.10")) {
						SpawnName = R1_7_10.CheckGaia();
					}else if(version.equals("1.12.2")){
						SpawnName = R1_12_2.CheckGaia();
					}else if(version.equals("1.16.1")){
						SpawnName = R1_16_1.CheckGaia();
					}else if(version.equals("1.14.4")){
						SpawnName = R1_14_4.CheckGaia();
					}else if(version.equals("1.7.2")){
						SpawnName = R1_7_2.CheckGaia();
					}else if(version.equals("1.6.4")){
						SpawnName = R1_6_4.CheckGaia();
					}

				}
				if(e.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-CultistPortal")) {
					SpawnName = "Crimson_Portal";
				}
				if(e.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-CultistLeader")) {
					SpawnName = "Praetor_Bastian_the_Infested";

				}
				if(e.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-TaintacleGiant")) {
					SpawnName = "Taintacle";

				}
				if(e.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-EldritchGolem")) {
					SpawnName = "Shudde_M'ell_the_Mighty";

				}


				if(e.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-EldritchWarden")) {
					SpawnName = "Grim_Eldritch_Construct";
				}

				if(getConfig().getBoolean(SpawnName + ".Switch") == false) {
					return;
				}
				Damageable Damageable = (Damageable) e.getEntity();
				if(!(getConfig().getDouble(SpawnName + ".NormalHealth") == Damageable.getMaxHealth())) {
					return;
				}
				Damageable.setMaxHealth(getConfig().getDouble(SpawnName + ".Health"));
				Damageable.setHealth(getConfig().getDouble(SpawnName + ".Health"));


				if(getConfig().getBoolean(SpawnName + ".AntiPickUp")) {
					e.getEntity().setCanPickupItems(false);
				}


				if(getConfig().getBoolean(SpawnName + ".BossNameStill")) {
					e.getEntity().setCustomNameVisible(true);
				}


				if(getConfig().getBoolean(SpawnName + ".speed")) {
					int BuffLevel = getConfig().getInt(SpawnName + ".speedLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".speedTime") * 20;
					e.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, BuffTime, BuffLevel));
				}


				if(getConfig().getBoolean(SpawnName + ".antifire")) {
					int BuffLevel = getConfig().getInt(SpawnName + ".antifireLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".antifireTime") * 20;
					e.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, BuffTime, BuffLevel));
				}

				if(getConfig().getBoolean(SpawnName + ".DamageBuff")) {
					int BuffLevel = getConfig().getInt(SpawnName + ".DamageBuffLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".DamageBuffTime") * 20;
					e.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, BuffTime, BuffLevel));
				}


				if(getConfig().getBoolean(SpawnName + ".SpawnBoardcastSwitch")) {
					for(int line = 0; line < getConfig().getStringList(SpawnName + ".SpawnBoardcast.List").size() ; line++) {
						String SpawnInfo = getConfig().getStringList(SpawnName + ".SpawnBoardcast.List").get(line);
						if(SpawnInfo.contains("<Priex>")) {
							SpawnInfo = SpawnInfo.replaceAll("<Priex>", Priex);
						}
						if(SpawnInfo.contains("&")) {
							SpawnInfo = SpawnInfo.replaceAll("&", "§");
						}

						if(SpawnInfo.contains("<WorldName>")) {
							String WorldName = e.getEntity().getWorld().getName();
							for(int WorldLine = 0; WorldLine < getConfig().getStringList("Alias.Worlds").size() ; WorldLine++) {
								String TempWorldName = getConfig().getStringList("Alias.Worlds").get(WorldLine);
								if(TempWorldName.equalsIgnoreCase(WorldName)) {

									String ReplaceWorldName = getConfig().getStringList("Alias.Replace").get(WorldLine);
									if(ReplaceWorldName.contains("&")) {
										ReplaceWorldName = ReplaceWorldName.replaceAll("&", "§");
									}
									SpawnInfo = SpawnInfo.replaceAll("<WorldName>", ReplaceWorldName);
								}
							}
						}


						if(SpawnInfo.contains("<MaxHealth>")) {
							Damageable DamageableBoss = (Damageable) e.getEntity();
							double MaxHealth = DamageableBoss.getMaxHealth();
							SpawnInfo = SpawnInfo.replaceAll("<MaxHealth>", String.valueOf(MaxHealth));
						}
						String X = String.valueOf((int)e.getEntity().getLocation().getX());
						String Y = String.valueOf((int)e.getEntity().getLocation().getY());
						String Z = String.valueOf((int)e.getEntity().getLocation().getZ());
						if(SpawnInfo.contains("<X>")) {
							SpawnInfo = SpawnInfo.replaceAll("<X>", X);
						}
						if(SpawnInfo.contains("<Y>")) {
							SpawnInfo = SpawnInfo.replaceAll("<Y>", Y);
						}
						if(SpawnInfo.contains("<Z>")) {
							SpawnInfo = SpawnInfo.replaceAll("<Z>", Z);
						}

						if(SpawnInfo.contains("<BossName>")) {
							SpawnInfo = SpawnInfo.replaceAll("<BossName>", getConfig().getString(SpawnName + ".Name"));
						}
						Bukkit.broadcastMessage(SpawnInfo);
					}
				}
















				e.getEntity().setCustomName(getConfig().getString(SpawnName + ".Name"));				
				this.cancel();
			}
		}.runTaskLater(this, 3L);







	}

	@EventHandler
	public void OnEntityDamageByEntity(EntityDamageByEntityEvent event) {
		int KillType = 0;
		if(event.getEntity().isDead()) {
			return;
		}

		if(event.getEntity() instanceof Player && !(event.getDamager() instanceof Player)) {
			KillType = 1;
			//boss回合

		}
		if(!(event.getEntity() instanceof Player) && event.getDamager() instanceof Player) {
			KillType = 2;
			//玩家回合
		}
		if(!(event.getEntity() instanceof Player) && event.getDamager() instanceof Projectile) {
			KillType = 2;
			//玩家回合
		}


		if(KillType == 1) {
			Player  p = (Player) event.getEntity();//玩家

			if(!(event.getDamager() instanceof LivingEntity)) {
				return;
			}
			LivingEntity damager = (LivingEntity) event.getDamager();//boss
			Damageable damageable = (Damageable) damager;
			//boss回合
			FEntity = event.getDamager();
			String SpawnName = null;
			if(version.equals("1.7.10")) {
				SpawnName = R1_7_10.get();
			}else if(version.equals("1.12.2")){
				SpawnName = R1_12_2.get();
			}else if(version.equals("1.16.1")){
				SpawnName = R1_16_1.get();
			}else if(version.equals("1.14.4")){
				SpawnName = R1_14_4.get();
			}else if(version.equals("1.7.2")){
				SpawnName = R1_7_2.get();
			}else if(version.equals("1.6.4")){
				SpawnName = R1_6_4.get();
			}
			if(event.getDamager().getType().getName().equalsIgnoreCase("Botania-botaniadoppleganger") || SpawnName.equalsIgnoreCase("Guardian-of-Gaia")) {
				FEntity = event.getDamager();
				if(version.equals("1.7.10")) {
					SpawnName = R1_7_10.CheckGaia();
				}else if(version.equals("1.12.2")){
					SpawnName = R1_12_2.CheckGaia();
				}else if(version.equals("1.16.1")){
					SpawnName = R1_16_1.CheckGaia();
				}else if(version.equals("1.14.4")){
					SpawnName = R1_14_4.CheckGaia();
				}else if(version.equals("1.7.2")){
					SpawnName = R1_7_2.CheckGaia();
				}else if(version.equals("1.6.4")){
					SpawnName = R1_6_4.CheckGaia();
				}
			}

			if(event.getDamager().getType().getName().equalsIgnoreCase("Thaumcraft-CultistPortal")) {
				SpawnName = "Crimson_Portal";

			}
			if(event.getDamager().getType().getName().equalsIgnoreCase("Thaumcraft-CultistLeader")) {
				SpawnName = "Praetor_Bastian_the_Infested";

			}
			if(event.getDamager().getType().getName().equalsIgnoreCase("Thaumcraft-TaintacleGiant")) {
				SpawnName = "Taintacle";

			}
			if(event.getDamager().getType().getName().equalsIgnoreCase("Thaumcraft-EldritchGolem")) {
				SpawnName = "Shudde_M'ell_the_Mighty";

			}


			if(event.getDamager().getType().getName().equalsIgnoreCase("Thaumcraft-EldritchWarden")) {
				SpawnName = "Grim_Eldritch_Construct";
			}

			for(int RecoverNameCS = 0; RecoverNameCS < getConfig().getStringList("List.OldName").size(); RecoverNameCS ++) {
				String TempStringRecover = getConfig().getStringList("List.NewName").get(RecoverNameCS);
				if(TempStringRecover.equals(SpawnName)) {
					SpawnName = getConfig().getStringList("List.OldName").get(RecoverNameCS);
				}
			}
			if(!(getConfig().getBoolean(SpawnName + ".Switch"))) {
				return;
			}
			if(!(damageable.getMaxHealth() == getConfig().getDouble(SpawnName + ".Health"))) {
				return;
			}


			if(getConfig().getBoolean(SpawnName + ".DamageSwitch")) {
				double SetDamage = getConfig().getDouble(SpawnName + ".Damage");
				event.setDamage(SetDamage);
			}

			FEntity.setCustomName(getConfig().getString(SpawnName + ".Name"));
		}

		if(KillType == 2) {
			//玩家回合

			if(!(event.getEntity() instanceof LivingEntity)) {
				return;
			}

			LivingEntity bedamage = (LivingEntity) event.getEntity();//boss
			Damageable damageable = (Damageable) bedamage;


			Entity damager = event.getDamager();
			if(!(damager instanceof Player) && !(damager instanceof Projectile)) {
				return;
			}
			Player player = null;
			if(event.getDamager() instanceof Projectile) {
				//攻击者是抛射物.
				Projectile YC = (Projectile) damager;
				ProjectileSource TestEntityYC = YC.getShooter();
				if(TestEntityYC instanceof Player) {
					player = (Player) TestEntityYC;
				}else {
					return;
				}

			}else {
				//攻击者不是抛射物.
				if(!(damager instanceof Player)) {
					return;
				}

				player = (Player) damager;
			}



			Location damageloc = player.getLocation();
			World world = player.getWorld();
			String SpawnName = null;
			FEntity = event.getEntity();
			if(version.equals("1.7.10")) {
				SpawnName = R1_7_10.get();
			}else if(version.equals("1.12.2")){
				SpawnName = R1_12_2.get();
			}else if(version.equals("1.16.1")) {
				SpawnName = R1_16_1.get();
			}else if(version.equals("1.14.4")){
				SpawnName = R1_14_4.get();
			}else if(version.equals("1.7.2")){
				SpawnName = R1_7_2.get();
			}else if(version.equals("1.6.4")){
				SpawnName = R1_6_4.get();
			}
			for(int RecoverNameCS = 0; RecoverNameCS < getConfig().getStringList("List.OldName").size(); RecoverNameCS ++) {
				String TempStringRecover = getConfig().getStringList("List.NewName").get(RecoverNameCS);
				if(TempStringRecover.equals(SpawnName)) {
					SpawnName = getConfig().getStringList("List.OldName").get(RecoverNameCS);
				}
			}
			String SpawnI = SpawnName;

			if(event.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-CultistPortal")) {
				SpawnName = "Crimson_Portal";

			}
			if(event.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-CultistLeader")) {
				SpawnName = "Praetor_Bastian_the_Infested";

			}
			if(event.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-TaintacleGiant")) {
				SpawnName = "Taintacle";

			}
			if(event.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-EldritchGolem")) {
				SpawnName = "Shudde_M'ell_the_Mighty";

			}


			if(event.getEntity().getType().getName().equalsIgnoreCase("Thaumcraft-EldritchWarden")) {
				SpawnName = "Grim_Eldritch_Construct";
			}
			if(event.getEntity().getType().getName().equalsIgnoreCase("Botania-botaniadoppleganger")|| SpawnName.equalsIgnoreCase("Guardian-of-Gaia")) {
				FEntity = event.getEntity();
				if(version.equals("1.7.10")) {
					SpawnName = R1_7_10.CheckGaia();
				}else if(version.equals("1.12.2")){
					SpawnName = R1_12_2.CheckGaia();
				}else if(version.equals("1.16.1")) {
					SpawnName = R1_16_1.CheckGaia();
				}else if(version.equals("1.14.4")){
					SpawnName = R1_14_4.CheckGaia();
				}else if(version.equals("1.7.2")){
					SpawnName = R1_7_2.CheckGaia();
				}else if(version.equals("1.6.4")){
					SpawnName = R1_6_4.CheckGaia();
				}

			}



			if(getConfig().getBoolean(SpawnName + ".Switch") == false) {
				return;
			}
			if(!(damageable.getMaxHealth() == getConfig().getDouble(SpawnName + ".Health"))) {
				return;
			}

			if(getConfig().getBoolean(SpawnName + ".BeDamageSwitch")) {
				double MaxDamage = getConfig().getDouble(SpawnName + ".BeDamage");
				double GetDamage = event.getDamage();
				if(GetDamage > MaxDamage) {
					event.setDamage(MaxDamage);
				}
			}

			if(getConfig().getBoolean(SpawnName + ".posion")) {
				Priex = getConfig().getString("Priex.Priex");
				double chance = Math.random() * 100;
				double BuffChance = getConfig().getDouble(SpawnName + ".posionchance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".posionLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".posionTime") * 20;
					player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {

						String NeiRong = getConfig().getString("Language.posion");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);

					}
				}

			}	


			double chance = Math.random() * 100;
			if(getConfig().getBoolean(SpawnName + ".fire")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".firechance");
				if(chance < BuffChance) {
					int FireTime = getConfig().getInt(SpawnName + ".fireTime");
					player.setFireTicks(FireTime * 20);
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.fire");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(FireTime));
						}
						player.sendMessage(NeiRong);
					}
				}

			}

			if(getConfig().getBoolean(SpawnName + ".slow")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".slowchance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".slowLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".slowTime") * 20;
					player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {

						String NeiRong = getConfig().getString("Language.slow");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);

					}
				}

			}

			if(getConfig().getBoolean(SpawnName + ".blind")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".blindchance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".blindLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".blindTime") * 20;
					player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.blind");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);
					}
				}

			}

			if(getConfig().getBoolean(SpawnName + ".wither")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".witherchance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".witherLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".witherTime") * 20;
					player.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.wither");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);
					}
				}

			}

			if(getConfig().getBoolean(SpawnName + ".weak")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".weakchance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".weakLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".weakTime") * 20;
					player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.weak");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);
					}
				}

			}
			if(getConfig().getBoolean(SpawnName + ".hunger")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".hungerchance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".hungerLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".hungerTime") * 20;
					player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.hunger");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);
					}
				}

			}

			if(getConfig().getBoolean(SpawnName + ".invisible")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".invisiblechance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".invisibleLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".invisibleTime") * 20;
					bedamage.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.invisible");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);
					}
				}

			}

			if(getConfig().getBoolean(SpawnName + ".heal")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".healchance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".healLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".healTime") * 20;
					bedamage.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.heal");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);
					}
				}

			}



			if(getConfig().getBoolean(SpawnName + ".KangXingTiSheng")) {
				double BuffChance = getConfig().getDouble(SpawnName + ".KangXingTiShengchance");
				if(chance < BuffChance) {
					int BuffLevel = getConfig().getInt(SpawnName + ".KangXingTiShengLevel") - 1;
					int BuffTime = getConfig().getInt(SpawnName + ".KangXingTiShengTime") * 20;
					bedamage.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, BuffTime, BuffLevel));
					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.KangXingTiSheng");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<BuffLevel>")) {
							NeiRong = NeiRong.replaceAll("<BuffLevel>", String.valueOf(BuffLevel + 1));
						}
						if(NeiRong.contains("<BuffTime>")) {
							NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(BuffTime/20));
						}

						player.sendMessage(NeiRong);
					}
				}

			}

			if(getConfig().getBoolean(SpawnName + ".summon")) {
				chance = Math.random() * 100;
				Priex = getConfig().getString("Priex.Priex");
				double SummonChance = getConfig().getDouble(SpawnName + ".summonchance");
				if(chance < SummonChance) {
					damageloc.setX(damageloc.getX() + 5);
					damageloc.setY(damageloc.getY() + 5);
					damageloc.setZ(damageloc.getZ() + 5);

					new BukkitRunnable() {
						@Override
						public void run() {
							int Creeper = getConfig().getInt(SpawnI + ".CREEPER");
							int Zombie = getConfig().getInt(SpawnI + ".ZOMBIE");
							int Cave_SPIDER = getConfig().getInt(SpawnI + ".Cave_SPIDER");
							int SPIDER = getConfig().getInt(SpawnI + ".SPIDER");
							int SKELETON = getConfig().getInt(SpawnI + ".SKELETON");
							int WITCH = getConfig().getInt(SpawnI + ".WITCH");
							int Bat = getConfig().getInt(SpawnI + ".BAT");
							int Ghast = getConfig().getInt(SpawnI + ".GHAST");
							int Blaze = getConfig().getInt(SpawnI + ".BLAZE");
							int Slime = getConfig().getInt(SpawnI + ".SLIME");
							int Giant = getConfig().getInt(SpawnI + ".GIANT");
							for(int zhaohuancishu = 0 ; zhaohuancishu < Zombie ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.ZOMBIE);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < Creeper ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.CREEPER);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < Cave_SPIDER ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.CAVE_SPIDER);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < SPIDER ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.SPIDER);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < SKELETON ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.SKELETON);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < WITCH ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.WITCH);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < Bat ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.BAT);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < Ghast ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.GHAST);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < Blaze ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.BLAZE);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < Slime ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.SLIME);
							}
							for(int zhaohuancishu = 0 ; zhaohuancishu < Giant ; zhaohuancishu ++) {
								world.spawnEntity(damageloc, EntityType.GIANT);
							}

							this.cancel();
						}
					}.runTaskTimer(this, 0L, 20L);


					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {


						String NeiRong = getConfig().getString("Language.summon");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						player.sendMessage(NeiRong);



					}
				}
			}

			if(getConfig().getBoolean(SpawnName + ".fireball")) {
				Priex = getConfig().getString("Priex.Priex");
				chance = Math.random() * 100;
				double JiNengChance = getConfig().getDouble(SpawnName + ".fireballchance");
				if(chance < JiNengChance) {
					List<Entity> gethereEntities = bedamage.getNearbyEntities(20,20,20);
					int zhaohuan = getConfig().getInt(SpawnName + ".fireballAmount");
					new BukkitRunnable() {
						@Override
						public void run() {
							for(int a=0;a<gethereEntities.size();a++){
								Entity entities = gethereEntities.get(a);
								if(entities instanceof Player) {
									Player entitiesPlayer = (Player) entities; 
									for(int zhaohuancishu = 0 ; zhaohuancishu < zhaohuan ; zhaohuancishu ++) {
										Location temploc = bedamage.getLocation();
										temploc.setY(temploc.getY() + 5);
										Fireball fireball = (Fireball) world.spawnEntity(temploc, EntityType.FIREBALL);
										fireball.setVelocity(entities.getVelocity());
										entitiesPlayer.damage(getConfig().getDouble(SpawnI + ".fireballDamage"));
									}

									if(getConfig().getBoolean(SpawnI + ".JiNengTiXingSwitch")) {
										String NeiRong = getConfig().getString("Language.fireball");
										if(NeiRong.contains("<priex>")) {
											NeiRong = NeiRong.replaceAll("<priex>", Priex);
										}
										entitiesPlayer.sendMessage(NeiRong);
									}



								}
							}

							this.cancel();
						}
					}.runTaskTimer(this, 0L, 20L);
				}
			}



			if(getConfig().getBoolean(SpawnName + ".fight")) {
				Priex = getConfig().getString("Priex.Priex");
				chance = Math.random() * 100;
				double JiNengChance = getConfig().getDouble(SpawnName + ".fightchance");
				float fightY = (float) getConfig().getInt(SpawnName + ".fightY");
				if(chance < JiNengChance) {
					player.setVelocity(new Vector(0, fightY, 0));

					if(getConfig().getBoolean(SpawnName + ".JiNengTiXingSwitch")) {
						String NeiRong = getConfig().getString("Language.fight");
						if(NeiRong.contains("<priex>")) {
							NeiRong = NeiRong.replaceAll("<priex>", Priex);
						}
						if(NeiRong.contains("<fightY>")) {
							NeiRong = NeiRong.replaceAll("<fightY>", String.valueOf(fightY));
						}
						player.sendMessage(NeiRong);
					}


				}
			}
			if(getConfig().getBoolean(SpawnName + ".light")) {
				chance = Math.random() * 100;
				double JiNengChance = getConfig().getDouble(SpawnName + ".lightchance");
				if(chance < JiNengChance) {
					int zhaohuan = getConfig().getInt(SpawnName + ".lightAmount");
					damageloc.setY(damageloc.getY() + 5);
					List<Entity> gethereEntities = bedamage.getNearbyEntities(20,20,20);
					new BukkitRunnable() {
						@Override
						public void run() {
							for(int a=0;a<gethereEntities.size();a++){
								Entity entities = gethereEntities.get(a);
								if(entities instanceof Player) {
									Player entitiesPlayer = (Player) entities; 
									Location temploc = entitiesPlayer.getLocation();
									for(int zhaohuancishu = 0 ; zhaohuancishu < zhaohuan ; zhaohuancishu ++) {
										world.strikeLightning(temploc);
										entitiesPlayer.damage(getConfig().getDouble(SpawnI + ".lightDamage"));
									}

									if(getConfig().getBoolean(SpawnI + ".JiNengTiXingSwitch")) {

										String NeiRong = getConfig().getString("Language.light");
										if(NeiRong.contains("<priex>")) {
											NeiRong = NeiRong.replaceAll("<priex>", Priex);
										}
										entitiesPlayer.sendMessage(NeiRong);



									}
								}
							}
							this.cancel();
						}
					}.runTaskTimer(this, 0L, 20L);

				}
			}

			if(getConfig().getBoolean(SpawnName + ".move")) {
				chance = Math.random() * 100;
				double JiNengChance = getConfig().getDouble(SpawnName + ".movechance");
				if(chance < JiNengChance) {
					new BukkitRunnable() {
						@Override
						public void run() {
							double chance = Math.random() * 100;
							Priex = getConfig().getString("Priex.Priex");
							if(!(getConfig().getBoolean(SpawnI + ".move"))) {

								return;
							}
							double SummonChance = getConfig().getDouble(SpawnI + ".movechance");
							if(chance < SummonChance) {
								int X = getConfig().getInt(SpawnI + ".X");
								int Y = getConfig().getInt(SpawnI + ".Y");
								int Z = getConfig().getInt(SpawnI + ".Z");
								damageloc.setX(damageloc.getX() + X);
								damageloc.setY(damageloc.getY() + Y);
								damageloc.setZ(damageloc.getZ() + Z);
								bedamage.teleport(damageloc);
								if(getConfig().getBoolean(SpawnI + ".JiNengTiXingSwitch")) {

									String NeiRong = getConfig().getString("Language.move");
									if(NeiRong.contains("<priex>")) {
										NeiRong = NeiRong.replaceAll("<priex>", Priex);
									}

									//修Final问题
									if(event.getDamager() instanceof Projectile) {
										//攻击者是抛射物.
										Projectile YC = (Projectile) damager;
										ProjectileSource TestEntityYC = YC.getShooter();
										if(TestEntityYC instanceof Player) {
											Player Sendplayer = (Player) TestEntityYC;
											Sendplayer.sendMessage(NeiRong);
										}else {
											return;
										}

									}else {
										//攻击者不是抛射物.
										if(!(damager instanceof Player)) {
											return;
										}

										Player Sendplayer = (Player) damager;
										Sendplayer.sendMessage(NeiRong);
									}


								}

							}


							this.cancel();
						}
					}.runTaskTimer(this, 0L, 20L);
				}
			}




			if(getConfig().getBoolean(SpawnName + ".lockmove")) {
				Priex = getConfig().getString("Priex.Priex");
				double lockmoveJiNengChance = getConfig().getDouble(SpawnName + ".lockmovechance");
				if(chance < lockmoveJiNengChance) {
					int lockmovetime = getConfig().getInt(SpawnName + ".lockmovetime");
					Location lockloc = player.getLocation();
					
					List<Entity> gethereEntities = bedamage.getNearbyEntities(20,20,20);
					for(int a=0;a<gethereEntities.size();a++){
						Entity entities = gethereEntities.get(a);
						if(entities instanceof Player) {
							Player entitiesPlayer = (Player) entities; 
							if(getConfig().getBoolean(SpawnI + ".JiNengTiXingSwitch")) {
								String NeiRong = getConfig().getString("Language.lockmove");
								if(NeiRong.contains("<priex>")) {
									NeiRong = NeiRong.replaceAll("<priex>", Priex);
								}
								if(NeiRong.contains("<BuffTime>")) {
									NeiRong = NeiRong.replaceAll("<BuffTime>", String.valueOf(lockmovetime));
								}
								entitiesPlayer.sendMessage(NeiRong);
								
							}
						}
						}
					new BukkitRunnable() {
						int time = 0;
						
						
						@Override
						public void run() {

								time++;
								if(time >= lockmovetime) {
									this.cancel();
								}
								
								List<Entity> gethereEntities = bedamage.getNearbyEntities(20,20,20);
								for(int b=0;b<gethereEntities.size();b++){
									Entity entities = gethereEntities.get(b);
									if(entities instanceof Player) {
										Player entitiesPlayer = (Player) entities; 
										entitiesPlayer.teleport(lockloc);
									}
								}
								
							
						}
					}.runTaskTimer(this, 20L, 20L);

				}

			}



			if(getConfig().getBoolean(SpawnName + ".movehere")) {
				Priex = getConfig().getString("Priex.Priex");
				double moveherechance = getConfig().getDouble(SpawnName + ".moveherechance");
				if(chance < moveherechance) {
					List<Entity> gethereEntities = bedamage.getNearbyEntities(20,20,20);
					Location temploc = bedamage.getLocation();
					temploc.setX(temploc.getX() + 2);
					temploc.setY(temploc.getY() + 1);
					temploc.setZ(temploc.getZ() + 2);
					new BukkitRunnable() {
						@Override
						public void run() {
							for(int a=0;a<gethereEntities.size();a++){
								Entity entities = gethereEntities.get(a);
								if(entities instanceof Player) {
									Player entitiesPlayer = (Player) entities; 
									entitiesPlayer.teleport(temploc);
									if(getConfig().getBoolean(SpawnI + ".JiNengTiXingSwitch")) {
										String NeiRong = getConfig().getString("Language.movehere");
										if(NeiRong.contains("<priex>")) {
											NeiRong = NeiRong.replaceAll("<priex>", Priex);
										}
										entitiesPlayer.sendMessage(NeiRong);
									}
								}

							}
							this.cancel();
						}
					}.runTaskTimer(this, 0L, 20L);
				}


			}








			String moveoutSwitch = getConfig().getString(SpawnName + ".moveout");
			if(moveoutSwitch.equalsIgnoreCase("true")) {
				Priex = getConfig().getString("Priex.Priex");

				double moveoutchance = getConfig().getDouble(SpawnName + ".moveoutchance");
				double moveoutX = getConfig().getDouble(SpawnName + ".moveoutX");
				double moveoutY = getConfig().getDouble(SpawnName + ".moveoutY");
				double moveoutZ = getConfig().getDouble(SpawnName + ".moveoutZ");
				if(chance < moveoutchance) {
					List<Entity> gethereEntities = bedamage.getNearbyEntities(20, 20, 20);
					new BukkitRunnable() {
						@Override
						public void run() {
							for(int a=0;a<gethereEntities.size();a++){
								Entity entities = gethereEntities.get(a);
								if(entities instanceof Player) {
									Player entitiesPlayer = (Player) entities; 
									Location temploc = entitiesPlayer.getLocation();
									temploc.setX(temploc.getX() + moveoutX);
									temploc.setY(temploc.getY() + moveoutY);
									temploc.setZ(temploc.getZ() + moveoutZ);
									entitiesPlayer.teleport(temploc);
									if(getConfig().getBoolean(SpawnI + ".JiNengTiXingSwitch")) {
										String NeiRong = getConfig().getString("Language.moveout");
										if(NeiRong.contains("<priex>")) {
											NeiRong = NeiRong.replaceAll("<priex>", Priex);
										}
										entitiesPlayer.sendMessage(NeiRong);
									}
								}

							}
							this.cancel();
						}
					}.runTaskTimer(this, 0L, 20L);
				}


			}
			FEntity.setCustomName(getConfig().getString(SpawnName + ".Name"));
		}

	}




	@EventHandler 
	public void OnEntityDeath(EntityDeathEvent event) {
		Entity Deadboss = event.getEntity();
		String CustomName = null;
		Damageable damageable = (Damageable) Deadboss;
		Entity killer = event.getEntity().getKiller();
		if(!(killer instanceof Player) && !(killer instanceof Projectile)) {
			return;
		}


		Player player = (Player) killer;
		if(event.getEntity().getKiller() instanceof Projectile) {
			Projectile YC = (Projectile) event.getEntity().getKiller();
			ProjectileSource TestEntityYC = YC.getShooter();
			if(TestEntityYC instanceof Player) {
				player = (Player) TestEntityYC;
			}
		}

		if(Deadboss instanceof Player) {
			return;
		}
		FEntity = Deadboss;
		String SpawnName = null;
		if(version.equals("1.7.10")) {
			SpawnName = R1_7_10.get();
		}else if(version.equals("1.12.2")){
			SpawnName = R1_12_2.get();
		}else if(version.equals("1.16.1")) {
			SpawnName = R1_16_1.get();
		}else if(version.equals("1.14.4")){
		    SpawnName = R1_14_4.get();
		}


		if(event.getEntity().getType().getName().equalsIgnoreCase("Botania-botaniadoppleganger")||SpawnName.equalsIgnoreCase("Guardian-of-Gaia")) {
			FEntity = Deadboss;
			if(version.equals("1.7.10")) {
				SpawnName = R1_7_10.CheckGaia();
			}else if(version.equals("1.12.2")){
				SpawnName = R1_12_2.CheckGaia();
			}else if(version.equals("1.16.1")) {
				SpawnName = R1_16_1.CheckGaia();
			}else if(version.equals("1.14.4")){
				SpawnName = R1_14_4.CheckGaia();
			}

		}





		for(int RecoverNameCS = 0; RecoverNameCS < getConfig().getStringList("List.OldName").size(); RecoverNameCS ++) {
			String TempStringRecover = getConfig().getStringList("List.NewName").get(RecoverNameCS);
			if(TempStringRecover.equals(SpawnName)) {
				CustomName = getConfig().getStringList("List.NewName").get(RecoverNameCS);
				SpawnName = getConfig().getStringList("List.OldName").get(RecoverNameCS);
			}
		}
		if(getConfig().getBoolean(SpawnName + ".Switch") == false) {
			return;
		}

		if(!(damageable.getMaxHealth() == getConfig().getDouble(SpawnName + ".Health"))) {
			return;
		}

		Priex = getConfig().getString("Priex.Priex");
		int level = getConfig().getInt(SpawnName + ".level");
		player.setLevel(player.getLevel() + level);
		player.sendMessage(Priex + "§f:§d您击杀了Boss获得了:" + level + "等级");
		double money = getConfig().getDouble(SpawnName + ".money");
		Bukkit.dispatchCommand(getServer().getConsoleSender(), "eco give " + player.getName() + " " + money);
		player.sendMessage(Priex + "§f:§d您击杀了Boss获得了:" + money + "金币");
		if(getConfig().getBoolean(SpawnName + ".broadcast")) {
			for(int hangshu = 0; hangshu < getConfig().getStringList("BroadcastInfo.line").size() ; hangshu++) {
				String GongGaoNeiRong = getConfig().getStringList("BroadcastInfo.line").get(hangshu);
				if(GongGaoNeiRong.contains("&")) {
					GongGaoNeiRong = GongGaoNeiRong.replaceAll("&", "§");
				}
				if(GongGaoNeiRong.contains("<priex>")) {
					GongGaoNeiRong = GongGaoNeiRong.replaceAll("<priex>", Priex);
				}
				if(GongGaoNeiRong.contains("<player>")) {
					GongGaoNeiRong = GongGaoNeiRong.replaceAll("<player>", player.getName());
				}


				if(GongGaoNeiRong.contains("<world>")) {
					String WorldName = Deadboss.getWorld().getName();
					for(int WorldLine = 0; WorldLine < getConfig().getStringList("Alias.Worlds").size() ; WorldLine++) {
						String TempWorldName = getConfig().getStringList("Alias.Worlds").get(WorldLine);
						if(TempWorldName.equalsIgnoreCase(WorldName)) {
							String ReplaceWorldName = getConfig().getStringList("Alias.Replace").get(WorldLine);
							if(ReplaceWorldName.contains("&")) {
								ReplaceWorldName = ReplaceWorldName.replaceAll("&", "§");
							}
							GongGaoNeiRong = GongGaoNeiRong.replaceAll("<world>", ReplaceWorldName);
						}
					}
				}


				if(GongGaoNeiRong.contains("<boss>")) {
					GongGaoNeiRong = GongGaoNeiRong.replaceAll("<boss>", getConfig().getString(SpawnName + ".Name"));
				}
				if(GongGaoNeiRong.contains("<money>")) {
					GongGaoNeiRong = GongGaoNeiRong.replaceAll("<money>", "§b" + money);
				}
				if(GongGaoNeiRong.contains("<level>")) {
					GongGaoNeiRong = GongGaoNeiRong.replaceAll("<level>", "§b" + level);
				}			
				Bukkit.broadcastMessage(GongGaoNeiRong);
			}
		}


		if(getConfig().getBoolean(SpawnName + ".commandSwitch")) {
			if(player.isOp() == false) {

				try {
					player.setOp(true);
					for(int commandline = 0; commandline < getConfig().getStringList(SpawnName + ".command").size() ; commandline++) {
						String CommandNeiRong = getConfig().getStringList(SpawnName + ".command").get(commandline);
						if(CommandNeiRong.contains("<player>")) {
							CommandNeiRong = CommandNeiRong.replaceAll("<player>", player.getName());
						}
						Bukkit.dispatchCommand(player, CommandNeiRong);
					}	
					player.setOp(false);
				}catch(Exception ex){
					player.setOp(false);
				}finally {
					player.setOp(false);
				}

			}else {
				for(int commandline = 0; commandline < getConfig().getStringList(SpawnName + ".command").size() ; commandline++) {
					String CommandNeiRong = getConfig().getStringList(SpawnName + ".command").get(commandline);
					if(CommandNeiRong.contains("<player>")) {
						CommandNeiRong = CommandNeiRong.replaceAll("<player>", player.getName());
					}
					Bukkit.dispatchCommand(player, CommandNeiRong);
				}
			}
		}



		if(getConfig().getBoolean(SpawnName + ".ChanceCommandSwitch")) {
			double chance = Math.random() * 100;
			double ChanceCommand = getConfig().getDouble(SpawnName + ".ChanceCommand");

			if(chance < ChanceCommand) {

				if(player.isOp() == false) {
					try {
						player.setOp(true);
						for(int commandline = 0; commandline < getConfig().getStringList(SpawnName + ".ChanceCommandList").size() ; commandline++) {
							String CommandNeiRong = getConfig().getStringList(SpawnName + ".ChanceCommandList").get(commandline);
							if(CommandNeiRong.contains("<player>")) {
								CommandNeiRong = CommandNeiRong.replaceAll("<player>", player.getName());
							}
							Bukkit.dispatchCommand(player, CommandNeiRong);
						}
						
						player.setOp(false);
					}catch(Exception ex){
						player.setOp(false);
					}finally {
						player.setOp(false);
					}

				}else {
					for(int commandline = 0; commandline < getConfig().getStringList(SpawnName + ".ChanceCommandList").size() ; commandline++) {
						String CommandNeiRong = getConfig().getStringList(SpawnName + ".ChanceCommandList").get(commandline);
						if(CommandNeiRong.contains("<player>")) {
							CommandNeiRong = CommandNeiRong.replaceAll("<player>", player.getName());
						}
						Bukkit.dispatchCommand(player, CommandNeiRong);
					}

				}

			}

		}
		if(getConfig().getBoolean(SpawnName + ".ClearBossDrop")) {
			event.getDrops().clear();
		}

	}


	@EventHandler
	public boolean onCommand(CommandSender sender,Command cmd,String Label,String[] args) {


		if(!(cmd.getName().equalsIgnoreCase("CustomFMXT"))) {
			return true;
		}

		if(sender instanceof Player) {
			Player p = (Player) sender;
			if(!(p.isOp())) {
				p.sendMessage("§6[CustomFMXT]:您没有权限！");
				return false;
			}
		}
		saveDefaultConfig();
		reloadConfig();
		sender.sendMessage("=============[封魔系统]=============");
		sender.sendMessage("重载成功！");
		sender.sendMessage("=============[封魔系统]=============");

		return false;

	}



}
